/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ar.com.wholeconsulting.pacc.tests.persistance;

import ar.com.wholeconsulting.pacc.model.Fabricante;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author Duco Pablo
 */
public class EntityRemover {

    public static void main(String[] args) {
        try {
            EntityManagerFactory factory = Persistence.createEntityManagerFactory("PACC");
            EntityManager manager = factory.createEntityManager();
            EntityTransaction transaction = manager.getTransaction();
            transaction.begin();

            Query query = manager.createNamedQuery(Fabricante.FIND_ALL);
            List<Fabricante> aceros = query.getResultList();
            for (Fabricante a : aceros) {
                //manager.remove(a);
                System.out.println(a.getNombre());
            }

            transaction.commit();

            manager.close();
            factory.close();

        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Error!");
        }
    }
}
